import groovy.jmx.builder.node.MBeanNodeData
import groovy.jmx.builder.node.SimpleNodeData
import javax.management.ObjectName

class MBeanNodeDataTest extends GroovyTestCase {
    void testMBeanNodeDataConstructor() {
        def observed = new ExposedTestBean(id: "TestBean")
        def data = new MBeanNodeData(name: new ObjectName("test:type=jmx"), object: observed, description: "Description")
        assert data != null
        assert data.name instanceof ObjectName
        assert data.name.toString() == "test:type=jmx"

        data.constructors = [new SimpleNodeData(value: "op1"), new SimpleNodeData(value: "op2")]
        assert data.constructors.size == 2

        data.operations = [new SimpleNodeData(value: "op1"), new SimpleNodeData(value: "op2")]
        assert data.operations.size == 2

        data.attributes = [new SimpleNodeData(value: "attr1"), new SimpleNodeData(value: "attr2")]
        assert data.attributes.size == 2
    }

    void testMBeanNodeDataSetter() {
        def data = new MBeanNodeData()
        data.object = new ObjectName("test:type=jmx")
        assert data.object != null
    }
}